package cn.doitedu.rtmk.data_moni;

import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.util.Bytes;

import java.io.IOException;
import java.util.Arrays;

public class UserProfileDataMoni {

    public static void main(String[] args) throws IOException {

        org.apache.hadoop.conf.Configuration conf = HBaseConfiguration.create();
        conf.set("hbase.zookeeper.quorum","doitedu:2181");
        Connection conn = ConnectionFactory.createConnection(conf);

        Table table = conn.getTable(TableName.valueOf("user_profile"));


        Put put1 = new Put(Bytes.toBytes(1L));
        put1.addColumn(Bytes.toBytes("f"),Bytes.toBytes("TAG0101"),Bytes.toBytes(150.0d));  // 月平均消费额
        put1.addColumn(Bytes.toBytes("f"),Bytes.toBytes("TAG0102"),Bytes.toBytes(350.0d));  // 月最大消费额

        Put put2 = new Put(Bytes.toBytes(2L));
        put2.addColumn(Bytes.toBytes("f"),Bytes.toBytes("TAG0101"),Bytes.toBytes(250.0d));  // 月平均消费额
        put2.addColumn(Bytes.toBytes("f"),Bytes.toBytes("TAG0102"),Bytes.toBytes(300.0d));  // 月最大消费额


        Put put3 = new Put(Bytes.toBytes(3L));
        put3.addColumn(Bytes.toBytes("f"),Bytes.toBytes("TAG0101"),Bytes.toBytes(100.0d));  // 月平均消费额
        put3.addColumn(Bytes.toBytes("f"),Bytes.toBytes("TAG0102"),Bytes.toBytes(150.0d));  // 月最大消费额


        table.put(Arrays.asList(put1,put2,put3));


        table.close();
        conn.close();
    }


}
